/**
 * @description 有关屏幕的处理,全屏和退出全屏的问题
 * @author kai.liu
 */
class Screen {
  constructor () {}
  /**
   * @param {string} element - element name 
   * @author kai.liu
   * @description 全屏方法 传入元素的类名   //  修改一下
   * @example 
   * this.$jxUtils.screen.fullscreen('.app')
   */
   fullscreen (element) {
     if (!document.querySelector(element)) {
      return console.error("请获取正确的类名")
     }
      let docElm = document.querySelector(element);
      //W3C
      if(docElm.requestFullscreen) {
        docElm.requestFullscreen();
      }
      //FireFox
      else if(docElm.mozRequestFullScreen) {
        docElm.mozRequestFullScreen();
      }
      //Chrome等
      else if(docElm.webkitRequestFullScreen) {
        docElm.webkitRequestFullScreen();
      }
      //IE11
      else if(elem.msRequestFullscreen) {
        elem.msRequestFullscreen();
      }
  }
 
  /**
   * 
   * @description  退出全屏 直接调用
   * @author kai.liu
   * @example this.$jxUtils.screen.exitFullscreen()
   */
 exitFullscreen () {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    }
    //FireFox
    else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    }
    //Chrome等
    else if (document.webkitCancelFullScreen) {
      document.webkitCancelFullScreen();
    }
    //IE11
    else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    }
  }
}

export default new Screen()